<html><title>SONAR Installation</title>
<head>
	{literal}
	<script type="text/javascript" src="../includes/jquery.js"></script>
	
	<script type="text/javascript">
		function validate()
		{
			var db_connection = $('#d_server').attr('value') == "" ||
								$('#d_database').attr('value') == "" ||
								$('#d_prefix').attr('value') == "" ||
								$('#d_username').attr('value') == "" ||
								$('#d_password').attr('value') == "";
				
			var etc = 	$('#d_root_folder').attr('value') == "" ||
						$('#d_sitename').attr('value') == "" ||
						$('#d_admin_username').attr('value') == "" ||
						$('#d_admin_password').attr('value') == "" ||
						$('#d_admin_email').attr('value') == "";
						
			var passwords =	$('#d_admin_password').attr('value') != "" &&
							$('#d_admin_password').attr('value') == 
							$('#d_admin_password_2').attr('value');
			
			if ($('#d_admin_password').attr('value') == "")
			{	$('#password_verify').html(""); }
			else if (passwords)
			{	$('#password_verify').html("<font color='green'><b>OK</b></font>"); }
			else
			{	$('#password_verify').html("<font color='red'><b>Passwords don't match.</b></font>"); }
			
			if(	db_connection )
				{
					$('#testconnection').attr('disabled',true);
					$('#submit').attr('disabled',true);
				}
			else
				{
					$('#testconnection').attr('disabled',false);
					if (!etc && passwords)
						{$('#submit').attr('disabled',false);}
					else
						{$('#submit').attr('disabled',true);}
				}
		}
	
		function test()
		{
			$.ajax(
			{
				type: 'POST',
				url: 'test.php',
				data: { server : $('#d_server').attr('value'),
						database : $('#d_database').attr('value'),
						username : $('#d_username').attr('value'),
						password : $('#d_password').attr('value')},
				success: function(data) { $('#test').html(data); }
			});
		}
	
		$("document").ready(function() 
		{
			$('#setupform').keyup(validate);
			$('#setupform').mouseup(validate);
			$('#testconnection').click(test);
		});
		
	</script>
	{/literal}
</head>
<body>

{if $mode == ""}
	<p style="font-family:arial;">Welcome to SONAR Installation
	<br /><br />
	Your PHP version is: {$php_version} {if $php_valid}{$good}{else}{$bad}{/if}
	<br /><br />
	Required Extentions: <br />
	MySQLi: {if $mysqli_valid}{$available}{else}{$bad}{/if}<br />
	<br />
	
	{if $installable == TRUE}
		<form id="setupform" method="POST" action="?action=install" style="font-family:arial;">
		<table>
			<tr><td style="text-align:right"><b>Database</b></td>			<td></td></tr>
			<tr><td style="text-align:right">Server:</td>	<td><input id="d_server" type="text" name="d_server" /></td></tr>
			<tr><td style="text-align:right">Name:</td>		<td><input id="d_database" type="text" name="d_database" /></td></tr>
			<tr><td style="text-align:right">Table prefix:</td>		<td><input id="d_prefix" type="text" name="d_prefix" value="sonar"/></td></tr>
			<tr><td style="text-align:right">Username:</td>			<td><input id="d_username" type="text" name="d_username" /></td></tr>
			<tr><td style="text-align:right">Password:</td>			<td><input id="d_password" type="password" name="d_password" /></td></tr>
			<tr><td></td>	<td><input id="testconnection" type="button" value="Test" disabled="true"/><span id="test"></span></td></tr>
			<tr><td style="text-align:right"><b>Website</b></td>			<td></td></tr>
			<tr><td style="text-align:right">Root folder:</td>		<td><input id="d_root_folder" type="text" name="d_root_folder" /></td></tr>
			<tr><td style="text-align:right">Site name:</td>			<td><input id="d_sitename" type="text" name="d_sitename" /></td></tr>
			<tr><td style="text-align:right">Admin username:</td>		<td><input id="d_admin_username" type="text" name="d_admin_username" /></td></tr>
			<tr><td style="text-align:right">Admin password:</td>		<td><input id="d_admin_password" type="password" name="d_admin_password" /></td></tr>
			<tr><td style="text-align:right">(again)</td>		<td><input id="d_admin_password_2" type="password" name="d_admin_password2" /> <span id="password_verify"></span></td></tr>
			<tr><td style="text-align:right">Admin email:</td>		<td><input id="d_admin_email" type="text" name="d_admin_email" /></td></tr>
			<tr><td></td>					<td><input id="submit" type="submit" value="Install" disabled="true"/></td></tr>
		</table>
		</form>
	{else}
		<p style="font-family:arial;">Your server configuration does not meet the requirements for this application. Please contact your webhost or IT department.</p>
	{/if}
	
{elseif $mode == "install"}

{/if}

</body></html>